class CommentedAnnouncement {
  String announcementId;
  String time;
  String publisherId;
  String importantLevel;
  String title;
  String content;
  String commentTime;
  String comment;

  CommentedAnnouncement(
      this.announcementId,
      this.time,
      this.publisherId,
      this.importantLevel,
      this.title,
      this.content,
      this.commentTime,
      this.comment);

  static CommentedAnnouncement fromMap(Map<String, dynamic> map) {
    String comment = map['comment'];
    if (comment.length > 9) {
      comment = comment.substring(0, 7) + "...";
    }
    return CommentedAnnouncement(
        map['announcementId'].toString(),
        map['time'].toString().substring(0, 10),
        map['publisherId'],
        map['importantLevel'],
        map['title'],
        map['content'],
        map['commentTime'],
        comment);
  }
}
